package com.kayt.cyberBar.cuser.business.dao.impl;

import java.sql.SQLException;
import java.util.LinkedHashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.kayt.cyberBar.common.PageData;
import com.kayt.cyberBar.common.dao.EntityDao;
import com.kayt.cyberBar.cuser.business.dao.IUserPictureDao;
import com.kayt.cyberBar.cuser.business.entity.po.BUserPicture;

@Repository("userPictureDao")
public class UserPictureDaoImpl implements IUserPictureDao {
	@Autowired
	private EntityDao entityDao;

	@Override
	public Integer save(BUserPicture entity) throws SQLException {
		if (entity != null) {
			entityDao.save(entity);
			return 0;
		} else {
			return -1;
		}
	}

	@Override
	public Integer update(BUserPicture entity) throws SQLException {
			if (entity != null) {
				entityDao.update(entity);
				return 0;
			} else {
				return -1;
			}
	}

	@Override
	public Integer delete(Integer id) {
			if (id != null) {
				BUserPicture BUserPicture = findById(id);
				if (BUserPicture != null) {
					entityDao.delete(BUserPicture);
					return 0;
				} else {
					return -1;
				}
			} else {
				return -1;
			}
	}

	@Override
	public BUserPicture findById(Integer id) {
			if (id != null) {
				return entityDao.findById(id, BUserPicture.class);
			} else {
				return null;
			}
	}

	@Override
	public PageData<BUserPicture> findByPage(int pageNum, int pageSize, String hql, Object[] params,
			LinkedHashMap<String, String> orderMap) throws SQLException {
		return this.entityDao.getPagingData(BUserPicture.class, pageNum, pageSize, hql, params, orderMap);
	}
}
